package cn.ccit.action;

import java.util.List;
import com.opensymphony.xwork2.ModelDriven;
import cn.ccit.entites.EnumSummary;
import cn.ccit.iservers.IEnumSummaryServers;
import cn.ccit.model.BaseModel;
import cn.ccit.servers.EnumSummaryServers;

/**
 * 
 * ClassName: EnumSummaryAction <br/>
 * Function: 枚举类的action发送json与接收参数的类. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2016年11月5日 下午3:08:31 <br/>
 * 
 * @author wanghao
 * @version 1.0
 * @since JDK 1.6
 */
public class EnumSummaryAction extends BaseAction implements
		ModelDriven<EnumSummary> {
	/**
	 * serialVersionUID:(版本号).
	 * 
	 * @since JDK 1.6
	 */
	private static final long serialVersionUID = 1L;
	private IEnumSummaryServers iEnumServers = new EnumSummaryServers();
	private EnumSummary enumSummary = new EnumSummary();

	@Override
	public String addData() {
		sendJsonData(iEnumServers.addEnumSummary(enumSummary),
				new BaseModel<EnumSummary>());
		return super.addData();
	}

	@Override
	public String removeData() {
		sendJsonData(iEnumServers.removeEnumSummary(enumSummary),
				new BaseModel<EnumSummary>());
		return super.removeData();
	}

	@Override
	public String changeDataInfo() {
		sendJsonData(iEnumServers.changeEnumSummaryInfo(enumSummary),
				new BaseModel<EnumSummary>(), enumSummary);
		return super.changeDataInfo();
	}

	@Override
	public String getDataList() {
		sendJsonDataList(iEnumServers.getSomeEnumSummaries(startId, limit),
				new BaseModel<List<EnumSummary>>());
		return super.getDataList();
	}

	@Override
	public EnumSummary getModel() {
		return enumSummary;
	}

	@Override
	public String sreachDataById() {
		EnumSummary es=iEnumServers.searchEnumSummaryByID(enumSummary.getId());
		sendJsonData(
				es != null,
				new BaseModel<EnumSummary>(),
				es);
		return super.sreachDataById();
	}

	@Override
	public String sreachDataByName() {
		sendJsonDataList(iEnumServers.getEnumByEnumType(enumSummary.getName()),
				new BaseModel<List<EnumSummary>>());
		return super.sreachDataByName();
	}

}
